/** testboxing.d - 
 Written in the D programming language 1.0
Authors:	Wei Li <oldrev@gmail.com>
Copyright:	Copyright (c) 2007 by Wei Li.
License:	BSD
*/

module test.base.teststring;

import dotmars.base.string;

import dotmars.test.core;

class StringTestCase : TestCase!(StringTestCase)
{
	this()
	{
		register("testAny", &testAny);
	}

	void testAny()
	{
		char* stringz = "ABCDEF\0";
		assertTrue(cstrlen(stringz) == 6);


		string str = "ABCDEFG";
		string sub = "EFG";
		assertTrue(compare(sub, "EFG") == 0);
		assertTrue(compare(sub, str.substring(4, 3)) == 0);
		assertTrue(str.indexOf('F') == 5);
		assertTrue(str.lastIndexOf('Z') < 0);
		assertTrue(str.startsWith("ABC"));
		assertTrue(str.endsWith("EFG"));
		assertTrue(str.indexOfAny("XYZC") == 2);
		assertTrue(str.lastIndexOfAny("XYZB") == 1);
	}
}

